#include "proj.h"

extern int16 Foc_PwmCntr1;
extern int16 Foc_PwmCntr2;
extern int16 Foc_PwmCntr3;

void PwmOutput_initalize()
{
	/* PWM-Ausgang aktivieren */
	TIM_CtrlPWMOutputs(TIM1, ENABLE);
}

void PwmOutput_step()
{
	if (Foc_PwmCntr1 < 0)
	{
		Foc_PwmCntr1 = 0;
	}
	if (Foc_PwmCntr2 < 0)
	{
		Foc_PwmCntr2 = 0;
	}
	if (Foc_PwmCntr3 < 0)
	{
		Foc_PwmCntr3 = 0;
	}

	TIM_SetCompare1(TIM1, Foc_PwmCntr1);
	TIM_SetCompare2(TIM1, Foc_PwmCntr2);
	TIM_SetCompare3(TIM1, Foc_PwmCntr3);
}

/*
 * 1 2 3 x
 * 1 3 2 x
 * 2 1 3 x
 * 2 3 1 x
 * 3 2 1 x
 * 3 1 2 x
 */

